<template>
  <div class="container">
    <div class="popupdl">
        <button type="button" class="closeone" @click="closedl">x</button>
        <div class="body">
            <div class="biaoyudl">欢迎登录</div>
            <div class="tishiti"><span v-show="dltShow">提示：{{ dltishi }}</span></div>
            <div class="boxint">
                <div class="img"><img class="imgic" src="../../assets/img/phone.png" alt=""></div>
                <div class="val"><input class="inptdl" type="text" placeholder='请输入手机号码' v-model="dlform.mobile"></div>
            </div>
            <!-- <div class="yanzhengts">手机号码格式错误,请重新输入。</div> -->
            <!-- <div class="boxint">
                <div class="img"><img class="imgic" src="../../assets/img/yanzhengma.png" alt=""></div>
                <div class="val"><input class="inptdl" type="text" placeholder='请输入验证码' v-model="dlform.yanzhen"></div>
                <span class="yzm"><button class="yzmb">获取验证码</button></span>
            </div> -->
            <div class="boxint">
                <div class="img"><img class="imgic" src="../../assets/img/mima.png" alt=""></div>
                <div class="val"><input class="inptdl" type="password" placeholder='请输入密码' v-model="dlform.password"></div>
            </div>
            <!-- <div class="yanzhengts">密码错误,请重新输入。</div> -->
            <div class="mima pointer" @click="close2">找回密码</div>
            <div class="dlbtn pointer" @click="denluform">登录</div>
        </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'popup',
  data() {
      return {
          isPopupVisibleZh: true,
          dlform: {
            mobile:'',
            password:''
          },
          dlshuju: '',
          dltShow:false,
          dltishi:''
      }
  },
  methods:{
    closedl (){
      this.$emit('closedl')
    },
    close2 (){
      this.$emit('close2',this.isPopupVisibleZh)
    },
    async denluform() {
        var dl = new FormData()
        dl.set('mobile',this.dlform.mobile)
        dl.set('password',this.dlform.password)
        // const data = await this.$http.post('/app/user/sendVercode.do',`mobile=${this.zcform.mobile}&updateType=${this.zcform.updateType}`)
        const { data: res } = await this.$http.post('app/user/login.do',dl)
        console.log(res)
        if (res.code !== 0){
          this.dltShow = true
          this.dltishi = res.msg
          var _that = this
          setTimeout(function(){
            _that.dltShow =false
          },3000);
        }else{
          console.log('登录成功')
        this.dlshuju = res.data
        window.localStorage.setItem('yonghuxinxi', JSON.stringify(this.dlshuju));
        console.log('从本地拿用户信息')
        console.log(window.localStorage.getItem('yonghuxinxi'))
        console.log(this.dlshuju)
        this.$emit('dlshuju', this.dlshuju)
        this.$router.push({
        name:'home',
        query: {
          sutankuang: true,
          msg:'登录成功'
        }
      })
        }
    }
  }

}
</script>

<style>
  .container {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .popupdl {
    background: #FFFFFF;
    height: 360px;
    width: 400px;
  }
  .dl {
      font-size: 20px;
      font-weight: bold;
  }
  .closeone {
      width: 30px;
      height: 30px;
      font-size: 25px;
      color: #999999;
      background-color: #fff;
      border: 0;
      position: relative;
      left: 360px;
      top: 10px;
  }
  .body {
      width: 100%;
      height: 410px;
      padding: 15px;
  }
  .biaoyudl {
      font-size: 20px;
      font-weight: bold;
  }
  .boxint {
      position: relative;
      height: 40px;
      width: 360px;
      background-color: #F6F6F6;
      margin-top: 25px;
  }
  .mima {
      position: relative;
      margin-top: 10px;
      left: 295px;
      color: #3C87CF;
  }
  .dlbtn {
      margin-top: 20px;
      height: 40px;
      width: 360px;
      background-color: #FF8B19;
      line-height: 40px;
      text-align:center;
      color: #fff;
      border-radius: 25px;
  }
  .img {
      position: absolute;
      width: 40px;
      height: 40px;
      line-height: 40px;
      top: 7px;
      left: 20px;
  }
  .imgic {
      width: 20px;
      height: 25px;
  }
  .val {
      position: absolute;
      left: 60px;
      height: 40px;
      line-height: 40px;
  }
  .inptdl {
      height: 32px;
      background:  #F6F6F6;
      border: 0;
      outline: none;
  }
  .yzm {
      position: absolute;
      line-height: 40px;
      right: 20px;
  }
  .yzmb {
      height: 40px;
      border: 0;
      background-color:#FAFAFA;
  }
</style>